package com.prs.crm.domain.purchase;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

import com.prs.crm.domain.FlowCodeEntity;
import com.prs.crm.domain.store.StoreRoom;

/**
 * @author 兰小刚
 * @version 创建时间：2010-7-19 下午16:09:28 类说明
 */
@Entity
@Table(name = "purchase_purchaseStoreIn")
public class PurchaseStoreIn extends FlowCodeEntity {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;
	/**
	 * 入库主题
	 */
	private String storeName;
	/**
	 * 入库日期
	 */
	private Date storeInDate;
	/**
	 * 入库仓库
	 */
	@ManyToOne
	private StoreRoom rooms;
	/**
	 * 入库信息
	 */
	@OneToOne
	private PurchaseOrder purchaseOrder;

	@Lob
	private String remark;
	@OneToMany(mappedBy = "purchaseStoreIn")
	@OrderBy
	@Cascade( { org.hibernate.annotations.CascadeType.ALL,
			org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
	private Set<PurchaseStoreInDetail> details;

	/**
	 * 批号
	 * 
	 * @return
	 */
	private String batchNum;
	/**
	 * 出库状态
	 */
	@Column(columnDefinition = "Integer(11) default '0'")
	private Integer outState;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getStoreName() {
		return storeName;
	}

	public void setStoreName(String storeName) {
		this.storeName = storeName;
	}

	public Date getStoreInDate() {
		return storeInDate;
	}

	public void setStoreInDate(Date storeInDate) {
		this.storeInDate = storeInDate;
	}

	public StoreRoom getRooms() {
		return rooms;
	}

	public void setRooms(StoreRoom rooms) {
		this.rooms = rooms;
	}

	public PurchaseOrder getPurchaseOrder() {
		return purchaseOrder;
	}

	public void setPurchaseOrder(PurchaseOrder purchaseOrder) {
		this.purchaseOrder = purchaseOrder;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getBatchNum() {
		return batchNum;
	}

	public void setBatchNum(String batchNum) {
		this.batchNum = batchNum;
	}

	public Set<PurchaseStoreInDetail> getDetails() {
		return details;
	}

	public void setDetails(Set<PurchaseStoreInDetail> details) {
		this.details = details;
	}

	public void addDetail(PurchaseStoreInDetail detail) {
		if (details == null)
			details = new HashSet<PurchaseStoreInDetail>();
		detail.setPurchaseStoreIn(this);
		details.add(detail);
	}

	public Integer getOutState() {
		return outState;
	}

	public void setOutState(Integer outState) {
		this.outState = outState;
	}

}
